/**
 * Mock数据入口
 */
import Mock from 'mockjs'
import { param2Obj } from './utils'
import messageApi from './modules/message'
import searchApi from './modules/search'
import materialApi from './modules/material'
import { setupAssetMock } from './modules/asset'
import { setupFinanceMock } from './modules/finance'
import { setupMaterialMock } from './modules/material'
import { setupProfileMock } from './modules/profile'
import { setupTodoMock } from './modules/todo'

// 设置模拟响应延迟时间
Mock.setup({
  timeout: '100-600'
})

// 消息相关接口
Mock.mock(/\/api\/messages$/, 'get', messageApi.getMessages)
Mock.mock(/\/api\/messages\/unread\/count$/, 'get', messageApi.getUnreadCount)
Mock.mock(/\/api\/messages\/\d+$/, 'get', messageApi.getMessage)
Mock.mock(/\/api\/messages\/\d+\/read$/, 'put', messageApi.markAsRead)
Mock.mock(/\/api\/messages\/read\/batch$/, 'put', messageApi.batchMarkAsRead)
Mock.mock(/\/api\/messages\/read\/all$/, 'put', messageApi.markAllRead)
Mock.mock(/\/api\/messages\/\d+$/, 'delete', messageApi.deleteMessage)

// 搜索相关接口
Mock.mock(/\/api\/search$/, 'get', searchApi.search)
Mock.mock(/\/api\/search\/suggestions$/, 'get', searchApi.getSuggestions)
Mock.mock(/\/api\/search\/hot$/, 'get', searchApi.getHotSearches)
Mock.mock(/\/api\/search\/history$/, 'post', searchApi.recordSearch)
Mock.mock(/\/api\/search\/history$/, 'delete', searchApi.clearSearchHistory)

// 物资相关接口
Mock.mock(/\/api\/materials$/, 'get', materialApi.getMaterials)
Mock.mock(/\/api\/materials\/categories$/, 'get', materialApi.getMaterialCategories)
Mock.mock(/\/api\/materials\/\d+$/, 'get', materialApi.getMaterialDetail)
Mock.mock(/\/api\/materials\/\d+\/related$/, 'get', materialApi.getRelatedMaterials)
Mock.mock(/\/api\/materials\/\d+\/apply-records$/, 'get', materialApi.getMaterialApplyRecords)
Mock.mock(/\/api\/materials\/favorites$/, 'get', materialApi.getFavoriteMaterials)
Mock.mock(/\/api\/materials\/apply$/, 'post', materialApi.applyMaterial)
Mock.mock(/\/api\/materials\/\d+\/favorite$/, 'put', materialApi.toggleFavoriteMaterial)
Mock.mock(/\/api\/materials$/, 'post', materialApi.addMaterial)
Mock.mock(/\/api\/materials\/\d+$/, 'put', materialApi.updateMaterial)
Mock.mock(/\/api\/materials\/\d+$/, 'delete', materialApi.deleteMaterial)

// 物资管理新API接口
Mock.mock(/\/api\/material\/report/, 'get', materialApi.getMaterialReport)

// 其他模块的Mock设置
setupAssetMock()
setupFinanceMock()
setupProfileMock()
setupTodoMock()

export default Mock 